package com.quanyan.club.service.impl;

import com.alibaba.dubbo.common.utils.CollectionUtils;
import com.quanyan.club.entity.db.TbOrderRefund;
import com.quanyan.club.entity.db.TbOrderRefundExample;
import com.quanyan.club.mapper.TbOrderRefundMapper;
import com.quanyan.club.service.ClubRefundService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Hugo.Wwg
 * @Since 2016-07-07
 */
@Service
public class ClubRefundServiceImpl implements ClubRefundService {

    @Autowired
    private TbOrderRefundMapper tbOrderRefundMapper;

    @Override
    public TbOrderRefund queryOneTbOrderRefundRecord(Integer uid, String refundOrderNo) {
        TbOrderRefundExample tbOrderRefundExample = new TbOrderRefundExample();
        tbOrderRefundExample.createCriteria().andRefundUidEqualTo(uid).
                andRefundOrderNoEqualTo(refundOrderNo);

        List<TbOrderRefund> tbOrderRefunds =
                tbOrderRefundMapper.selectByExample(tbOrderRefundExample);
        if (CollectionUtils.isEmpty(tbOrderRefunds)) {
            return null;
        }

        return tbOrderRefunds.get(0);
    }
}
